<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
		<script type="text/javascript" src="${path}/script/affixUpload.js">
</script>
		<link rel="stylesheet" href="${path }/css/affixUpload.css"
			type="text/css"></link>
	</head>
	<body id="master">
		<script type="text/javascript">
$(function() {
	var actionPath = "${path}/affix/index/upload/SALEPRODUCT";
	var div = 'sfaUpload'
	for (i = 1; i < 9; i++) {
		actionPath = "${path}/affix/index/upload/SALEPRODUCT" + i;
		div = div + 'i';
		//alert(div);
		sfaUpload.init(actionPath, div, i);
	}
	//sfaUpload.init(actionPath, div);
})

function ajaxSubmit(actionUrl, affixmainid, msg) {
	var affixStr1 = "";
	var affixStr2 = "";
	var affixStr3 = "";
	var affixStr4 = "";
	var affixStr5 = "";
	var affixStr6 = "";
	var affixStr7 = "";
	var affixStr8 = "";
	var otherInfo = $("#otherInfo").val();
	//alert(otherInfo);
	if (sfaUpload.getIsUploading()) {
		art.dialog( {
			content : "文件正在上传,请先取消上传文件！",
			lock : true,
			ok : true
		});
		return;
	}

	$(".uoloadedFile1").each(
			function(i, o) {
				var obj = $(o);
				affixStr1 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";

			});
	$(".uoloadedFile2").each(
			function(i, o) {
				var obj = $(o);
				affixStr2 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";

			});
	$(".uoloadedFile3").each(
			function(i, o) {
				var obj = $(o);
				affixStr3 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";
			});
				
	
	$(".uoloadedFile4").each(
			function(i, o) {
				var obj = $(o);
				affixStr4 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";
			});
			
			
	$(".uoloadedFile5").each(
			function(i, o) {
				var obj = $(o);
				affixStr5 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";
			});
	$(".uoloadedFile6").each(
			function(i, o) {
				var obj = $(o);
				affixStr6 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";
			});
	$(".uoloadedFile7").each(
			function(i, o) {
				var obj = $(o);
				affixStr7 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";
			});
	$(".uoloadedFile8").each(
			function(i, o) {
				var obj = $(o);
				affixStr8 += obj.attr("SALEAFFIXITEMID") + ";"
						+ obj.attr("isDel") + ";;";
			});
	art.dialog( {
		lock : true,
		content : '确定' + msg + '吗?',
		ok : function() {
			art.dialog( {
				id : "loading",
				lock : true,
				drag : false,
				resize : false,
				title : "正在提交..."
			});
			
			$.post(actionUrl, {
				affixmainid : affixmainid,
				affixStr1 : affixStr1,
				affixStr2 : affixStr2,
				affixStr3 : affixStr3,
				affixStr4 : affixStr4,
				affixStr5 : affixStr5,
				affixStr6 : affixStr6,
				affixStr7 : affixStr7,
				affixStr8 : affixStr8,
				 
				otherInfo : otherInfo,
			}, function(result) {
				 
				art.dialog( {
					id : 'loading'
				}).close();//关闭等待框 
					result = $("<span>" + result + "</span>").text();
					var obj = eval('(' + result + ')');
					
					//alert(result);
					if (obj.result) {
						art.dialog( {
							icon : "succeed",
							content : msg + "成功!",
							lock : true,
							ok : function() {
								history.go(-1);
							}
						});
					} else {
						art.dialog( {
							icon : "error",
							content : msg + "失败!错误消息:" + obj.message,
							lock : true,
							ok : true
						});
					}

				})
			return true;
		},
		cancelVal : '关闭',
		cancel : true
	});
}
</script>
		<body>
			<sfa:mainHeader></sfa:mainHeader>
			<div class="webpart3 contentarea">
				<div class="webpart-head">
					<div class="webpart-head-item">
						<c:if test="${!isPublished}">发布</c:if>
						<c:if test="${isPublished}">修改</c:if>
						产品
					</div>
				</div>
				<div class="webpart-main">
					<div class="webpart-main-item" style="padding: 15px;">
						<div class="d_formitem">
							<table cellspacing="0" cellpadding="0" class="formitem">
								<tr>
									<td width="20%">
										<span>产品编码：</span>
									</td>
									<td valign="middle">
										${productInfo.productcode}
									</td>
								</tr>
								<tr>
									<td>
										<span>产品名称：</span>
									</td>
									<td>
										${productInfo.productname}
									</td>
								</tr>
								<tr>
									<td>
										<span>产品类型：</span>
									</td>
									<td>
										${productInfo.producttypename}
									</td>
								</tr>
								<tr>
									<td>
										<span>供应商：</span>
									</td>
									<td>
										${productInfo.providername}
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<span>销售状态：</span>
									</td>
									<td>
										${productInfo.salestatusname}
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<span>起售时间：</span>
									</td>
									<td>
										<fmt:formatDate value="${productInfo.salestartdate}"
											pattern="yyyy-MM-dd" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<span>止售时间：</span>
									</td>
									<td>
										<fmt:formatDate value="${productInfo.saleenddate}"
											pattern="yyyy-MM-dd" />
									</td>
								</tr>
								<tr>
									<td style="vertical-align: middle;">
										产品介绍：
									</td>
									<td>

										<textarea rows="2" cols="15" id="otherInfo" name="otherInfo"
											style="width: 300px; height: 70px;">${saleproduct.otherinfo}</textarea>
									</td>
								</tr>
							</table>
						</div>

						<span class="webpart-head-item" style="font-weight: bold;">上传附件
						</span>
						<hr />
						<div class="in">
							<table>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">产品条框</span>
									</td>
									<td>
										<div id="fileList1">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList1}" var="affixItem">
													<div class="uoloadedFile1" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadi"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">产品佣金率</span>
									</td>
									<td>
										<div id="fileList2">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList2}" var="affixItem">
													<div class="uoloadedFile2" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadii"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">产品费率</span>
									</td>
									<td>
										<div id="fileList3">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList3}" var="affixItem">
													<div class="uoloadedFile3" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadiii"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">培训资料</span>
									</td>
									<td>
										<div id="fileList4">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList4}" var="affixItem">
													<div class="uoloadedFile4" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadiiii"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">彩页</span>
									</td>
									<td>
										<div id="fileList5">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList5}" var="affixItem">
													<div class="uoloadedFile5" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadiiiii"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">产品宣传</span>
									</td>
									<td>
										<div id="fileList6">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList6}" var="affixItem">
													<div class="uoloadedFile6" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadiiiiii"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">获奖信息</span>
									</td>
									<td>
										<div id="fileList7">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList7}" var="affixItem">
													<div class="uoloadedFile7" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadiiiiiii"></div>
									</td>
								</tr>
								<tr>
									<td width="40%">
										<span class="webpart-head-item" style="font-weight: bold;">视频信息</span>
									</td>
									<td>
										<div id="fileList8">
											<c:if test="${isPublished}">
												<c:forEach items="${affixList8}" var="affixItem">
													<div class="uoloadedFile8" isDel="n"
														AFFIXPATH="${affixItem.SALEAFFIXITEMFILEPATH}"
														FILENAME="${affixItem.SALEAFFIXITEMFILENAME}"
														SALEAFFIXITEMID="${affixItem.SALEAFFIXITEMID}">
														<span>${affixItem.SALEAFFIXITEMFILENAME}</span>
														<a href="javascript:void(0)"
															onclick="sfaUpload.delUpload(this)">&nbsp;删除</a>

													</div>
												</c:forEach>
											</c:if>
										</div>
										<div id="sfaUploadiiiiiiii"></div>
									</td>
								</tr>
							</table>
						</div>

						<span class="pageTitle"> </span>
						<hr />
						<c:if test="${!isPublished}">

							<a href="javascript:" class="linkbtn"
								onclick="ajaxSubmit('${path}/productandtrain/product/index/ajaxPublish','${productInfo.productid}','发布')">
								<span>发布</span> </a>
						</c:if>

						<c:if test="${isPublished}">
							<a href="javascript:" class="linkbtn"
								onclick="ajaxSubmit('${path}/productandtrain/product/index/ajaxEdit','${productInfo.productid}','修改')">
								<span>保存</span> </a>

						</c:if>
						&nbsp;&nbsp;
						<a href="javascript:" class="linkbtn" onclick="history.go(-1);">
							<span>返回</span> </a>
					</div>
					<div class="webpart-foot">
						<div class="webpart-foot-item">
						</div>
					</div>
				</div>
			</div>
			<sfa:mainFooter></sfa:mainFooter>
		</body>
</html>
